package com.fowo.api.controller.shipment.wfs;

import com.fowo.api.model.wms.order.WmsOrderCancesendgoodsAction;
import com.fowo.api.model.wms.order.WmsOrderVo;
import com.fowo.api.service.WmsOrderService;
import com.fowo.api.service.impl.WmsOrderServiceImpl;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import javax.annotation.Resource;
import java.util.List;

@Component()
public class wmsOrderCancesendgoodsAction implements WmsOrderCancesendgoodsAction {

    @Resource
    private WmsOrderServiceImpl wmsOrderServiceImpl;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void run(List<Long> idList) throws Exception {
        for (int i = 0; i < idList.size(); i++) {
            Long id = idList.get(i);
            cancesendgoods(id);
        }
    }

    private void cancesendgoods(Long id) throws Exception {
        WmsOrderVo voById = wmsOrderServiceImpl.getVoById(id);
        Assert.notNull(voById, "订单不存在");
        Assert.isTrue(voById.getStatus().equals("5"), "违规操作");
//        wmsOrderServiceImpl.cancesendgoods(List.of(id));
        //修改订单状态
        


    }

}
